#!/bin/bash
set -e

mkdir -p build
mkdir -p business_1/build
mkdir -p business_2/build

echo "==> Building business1.klib"
konanc -p library business_1/business1.kt -o business_1/build/business1

echo "==> Building business2.klib"
konanc -p library business_2/business2.kt -o business_2/build/business2

echo "==> Linking into final_lib.so"
konanc -p dynamic \
  -o build/final_lib \
  -target macos_x64 \
  -library $(pwd)/business_1/build/business1.klib \
  -library $(pwd)/business_2/build/business2.klib \
  common/common.kt

echo "✅ Done: build/final_lib.so"
